package com.example.modellol.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


import com.example.modellol.Fragment.EightFragment;
import com.example.modellol.Fragment.FirstFragment;
import com.example.modellol.Fragment.FiveFragment;
import com.example.modellol.Fragment.FouthFragment;
import com.example.modellol.Fragment.SecondFragment;
import com.example.modellol.Fragment.SevenFragment;
import com.example.modellol.Fragment.SixFragment;
import com.example.modellol.Fragment.ThirdFragment;

import java.util.HashMap;
import java.util.Map;

public class HomeVpAdapter extends FragmentPagerAdapter {


    private String text;
    private Map<Integer, Fragment> data;

    public HomeVpAdapter(@NonNull FragmentManager fm) {
        super(fm);
        data = new HashMap<>();
        data.put(0,new FirstFragment());
        data.put(1,new SecondFragment());
        data.put(2,new ThirdFragment());
        data.put(3,new FouthFragment());
        data.put(4,new FiveFragment());
        data.put(5,new SixFragment());
        data.put(6,new SevenFragment());
        data.put(7,new EightFragment());
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return text="关注";
            case 1:
                return text="推荐";
            case 2:
                return text="赛事";
            case 3:
                return text="云顶";
            case 4:
                return text="手游";
            case 5:
                return text="视频";
            case 6:
                return text="电视台";
            case 7:
                return text="活动";
        }
        return text;
    }
}